import request from '../common/request'

const getGroup = (id: number) => {
  return request({
    url: `/group/find/${id}`,
    method: 'GET'
  })
}

const getGroupList = () => {
  return request({
    url: `/group/list`,
    method: 'GET'
  })
}

const getGroupMembers = (id: number) => {
  return request({
    url: `/group/members/${id}`,
    method: 'GET'
  })
}

const updateGroup = (data: any) => {
  return request({
    url: '/group/modify',
    method: 'PUT',
    data
  })
}

const createGroup = (data: any) => {
  return request({
    url: '/group/create',
    method: 'POST',
    data
  })
}

const deleteGroup = (id: number) => {
  return request({
    url: `/group/quit/${id}`,
    method: 'DELETE'
  })
}

const kickGroup = (id: number, data: any) => {
  return request({
    url: `/group/kick/${id}`,
    method: 'DELETE',
    data
  })
}

const inviteGroup = (data: any) => {
  return request({
    url: "/group/invite",
    method: "POST",
    data,
  })
}

export const groupApi = {
  getGroup,
  getGroupList,
  getGroupMembers,
  updateGroup,
  createGroup,
  deleteGroup,
  kickGroup,
  inviteGroup
}